package com.qf.cosmetology.controller;

import com.qf.cosmetology.result.ResponseCode;
import com.qf.cosmetology.result.ResponseData;
import com.qf.cosmetology.service.PicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author xiyang
 */
@Api("PicApi")
@RestController
@RequestMapping("pics")
public class PicController {

    @Autowired
    private PicService picService;

    /**
     * @CrossOrigin   局部跨域注解
     * @param type
     * @param response
     * @return
     */
    @ApiOperation(value = "queryByType",notes = "通过图片类型获取对应的轮播图片或者是导航图片")
    @ApiImplicitParam(name = "type",value = "图片的类型")
    @GetMapping("/{type}")
    public ResponseData queryByType(@PathVariable String type, HttpServletResponse response){
        return picService.queryByType(type);
    }



    @ApiOperation(value = "queryid",notes = "通过图片id获取图片信息")
    @ApiImplicitParam(name = "id",value = "图片id")
    @GetMapping("/v1/{id}")
    public ResponseData queryById(@PathVariable Integer id){
        return new ResponseData(ResponseCode.SUCCESS,picService.queryById(id));
    }

    @ApiOperation(value = "queryAll",notes = "获取图片列表")
    @GetMapping("/all")
    public ResponseData queryAll(){
        return picService.queryAll();
    }





}
